package com.huan.controller;

import com.huan.VO.CategoryVo;
import com.huan.VO.PageVo;
import com.huan.domain.ResponseResult;
import com.huan.domain.entity.Category;
import com.huan.domain.entity.Link;
import com.huan.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
public class CategoryController {
    @Autowired
    private CategoryService categoryService;
    @GetMapping("/content/category/listAllCategory")
    public ResponseResult getAllCategory(){
        return categoryService.getAllCategory();
    }
    @GetMapping("/content/category/list")
    public ResponseResult<PageVo> getAllList(Integer pageNum, Integer pageSize, String name, String status){
        return categoryService.getAllList(pageNum,pageSize,name,status);
    }
    @PostMapping
    public ResponseResult add(@RequestBody Category category){
        return categoryService.add(category);
    }
    @GetMapping("{id}")
    public ResponseResult getLink(@PathVariable Long id){
        return categoryService.getLink(id);
    }
    @PutMapping
    public ResponseResult uplink(@RequestBody Category category){return categoryService.uplink(category);}
    @DeleteMapping("{id}")
    public ResponseResult deleteLink(@PathVariable Long id){
        return categoryService.deleteLink(id);
    }
}
